Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

request-promise

Package Overview
Dependencies
Maintainers
6
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

request-promise

The simplified HTTP request client 'request' with Promise support. Powered by Bluebird.

  • 4.2.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.4M
increased by2.37%
Maintainers
6
Weekly downloads
 
Created

What is request-promise?

The request-promise npm package is a popular HTTP client for making HTTP requests from Node.js. It is built on top of the 'request' package, providing a simplified way to make HTTP calls and process responses using promises instead of callbacks.

What are request-promise's main functionalities?

Simple HTTP GET requests

This feature allows you to perform simple HTTP GET requests and process the response as a string.

const rp = require('request-promise');

rp('http://example.com')
  .then(function (htmlString) {
    // Process html...
  })
  .catch(function (err) {
    // Handle error...
  });

HTTP requests with options

This feature allows you to perform HTTP requests with a full set of options, including query strings, headers, and automatic JSON parsing.

const rp = require('request-promise');

const options = {
  uri: 'http://api.example.com',
  qs: {
    access_token: 'my-token' // -> uri + '?access_token=my-token'
  },
  headers: {
    'User-Agent': 'Request-Promise'
  },
  json: true // Automatically parses the JSON string in the response
};

rp(options)
  .then(function (repos) {
    // Process repos...
  })
  .catch(function (err) {
    // Handle error...
  });

POST requests with form data

This feature allows you to perform HTTP POST requests with form data.

const rp = require('request-promise');

const options = {
  method: 'POST',
  uri: 'http://api.example.com/form',
  form: {
    key: 'value',
    another_key: 'another_value'
  },
  headers: {
    /* 'content-type': 'application/x-www-form-urlencoded' */ // Is set automatically
  }
};

rp(options)
  .then(function (parsedBody) {
    // POST succeeded...
  })
  .catch(function (err) {
    // POST failed...
  });

Other packages similar to request-promise

Keywords

FAQs

Package last updated on 22 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc